package goodenglish.infrastructure.repository.db;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class DbCreater {

	public static void main(String[] args) throws SQLException {
		reCreateDb();

	}

	public static void reCreateDb() {
		try {
			Connection conn;
			conn = DBUtil.getConnection();
			Statement stat = conn.createStatement();
			// 熟词
			stat.executeUpdate("drop table if exists ProfWord;");
			stat.executeUpdate("create table ProfWord (spell);");
			// 字幕
			stat.executeUpdate("drop table if exists Subt;");
			stat.executeUpdate("create table Subt (id  PRIMARY KEY ,name,lexicon_id);");
			// 字幕句子
			stat.executeUpdate("drop table if exists SubtSentence;");
			stat.executeUpdate("create table SubtSentence (subt_id,chStr,enStr,stimeStr,etimeStr,stime,etime);");
			// 词库
			stat.executeUpdate("drop table if exists Lexicon;");
			stat.executeUpdate("create table Lexicon (id  PRIMARY KEY ,name);");
			// 生词
			stat.executeUpdate("drop table if exists NewWord;");
			stat.executeUpdate("create table NewWord (id  PRIMARY KEY ,studyPlan_id,lexicon_id,rightCount,doneFlag,explain,spell,exampleSentStr);");
			// 学习计划
			stat.executeUpdate("drop table if exists StudyPlan;");
			stat.executeUpdate("create table StudyPlan (id  PRIMARY KEY ,lexicon_id,name,ctime,studyCount,currDoneFlag,totalDoneFlag,lastDoneTime);");
			// 字典
			stat.executeUpdate("drop table if exists Dictionary;");
			stat.executeUpdate("create table Dictionary (spell,explain,source);");
			DBUtil.closeConnection(conn);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
